<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
   
    	 public function index()
    {
        // var_dump($_SESSION);
        // exit;
    	// $adv=M('Advertise');
    	// $a=$adv->where('status=1')->select();
    	// $this->assign('adv',$a);
	 	
       
	  //   $flink=M('flink');
   //  	$f=$flink->where('linkstatus=1')->select();
   //  	$this->assign('list',$f);
	 	// $this->display();

	 	// $goods_type=D('goods_typeModel');
	 	// $a=$goods_type->fl();
	 	// var_dump($a);
	 	// exit;
        
  	 
    

    	 $Goodstype 	= M('goods_type');





    	 $goodsclasses 	= $Goodstype->where('pid=0')->limit()->select();


    	 $goodsclasses 	= $Goodstype->where('pid=0')->limit(8)->select();

    	 $goodsclasses 	= $Goodstype->where('pid=0')->order('id')->limit()->select();


    	$res = array();

    	foreach ($goodsclasses as $k => $v) {
            //取父级类的id
            $a=$v['id'];
            //取父类中子类的名称
            // $fullChild[] =[$v['type_name']=>$Goodstype->where("pid=$a")->select()];


            $fullChild[] =$Goodstype->where("pid=$a")->limit(6)->select();

            $res[] =$Goodstype->where("pid=$a")->limit()->select();

           


            // NSLog($v);
            
        }


/**
 列表导航
 */     

        //行1
        $fullChild11 = array_slice($res[0],0,6);
        $fullChild12 = array_slice($res[0],5,6);

        
        //行2
        $fullChild21 = array_slice($res[1],0,6);
        $fullChild22 = array_slice($res[1],5,6);

        
        //行3
        $fullChild31 = array_slice($res[2],0,6);
        $fullChild32 = array_slice($res[2],5,6);
        $fullChild33 = array_slice($res[2],5,6);

        //行4
        $fullChild4 = array_slice($res[3],0,6);


        //行5
        $fullChild5 = array_slice($res[4],0,6);

        //行6
        $fullChild6 = array_slice($res[5],0,6);

        //行7
        $fullChild7 = array_slice($res[6],0,6);


        //行8
        $fullChild81 = array_slice($res[7],0,6);

        $fullChild82 = array_slice($res[7],5,6);


        //行9
        $fullChild9 = array_slice($res[8],0,6);


        //行10
        $fullChild10 = array_slice($res[9],0,6);





        $floor          = D('Floor');

        $floorDetail    = M('flr_detail');

        $floorArr       = $floor->select();

        $floorDetailArr = array();
        //
        foreach ($floorArr as $key => $value) {

              
        $floorDetailArr[] = $floorDetail->where("floor_id=".$value['id'])->select();

        $data[$value['floor_name']] = $floor -> alias('fl')

        -> join('__FLR_DETAIL__ fd ON fd.max_id=fd.max_id') 

        -> join('__SKU_GOODS__ sg ON sg.proudct_id=fd.max_id') 

        -> join('__PRODUCT__ pro ON pro.id=fd.max_id')->where('fl.id='.$value['id'])

        ->select();
       

        }




        
/**
 打印调试区
 */
        // NSLog($data);
        // foreach ($data as $k => $v) {
            
        //     foreach ($v as $key => $value) {
        //         # code...
        //     }
        //    // NSLog($v);
        
        // }

 
        // NSLog(array_keys($data) );
        // NSLog($floorDetailArr);
        // NSLog($fullChild2);
      
        // NSLog($fullChild32);

        // NSLog($res);

/**
变量分配
 */


    	$this->assign('goodsclasses',$goodsclasses);
        

        //行1
        $this->assign('fullChild11',$fullChild11);

        $this->assign('fullChild12',$fullChild12);


        
        //行2
        $this->assign('fullChild21',$fullChild21);

        $this->assign('fullChild22',$fullChild22);



        //行
        $this->assign('fullChild31',$fullChild31);

        $this->assign('fullChild33',$fullChild33);

        $this->assign('fullChild33',$fullChild33);

        //行4
        $this->assign('fullChild4',$fullChild4);


        //行5
        $this->assign('fullChild5',$fullChild5);



        //行6
        $this->assign('fullChild6',$fullChild6);


        //行7
        $this->assign('fullChild7',$fullChild7);


        //行8
        $this->assign('fullChild81',$fullChild81);
        $this->assign('fullChild82',$fullChild82);



        //行9
        $this->assign('fullChild9',$fullChild9);


        //行10
        $this->assign('fullChild10',$fullChild10);

/**
liuchenghao
 */
        $this->assign('data',$data);
       $adv=M('Advertise');
        $a=$adv->where('status=1')->select();
        $this->assign('adv',$a);
        
       
        $flink=M('flink');
        $f=$flink->where('linkstatus=1')->select();
        $this->assign('list',$f);
  /**
end
  */     
    	
        $this->display();

    }
       
    
}